<!DOCTYPE html>
<html class="writer-html5" lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>selenium_driverless.scripts.switch_to &mdash; Selenium-Driverless 1.9.4 documentation</title>
      <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=80d5e7a1" />
      <link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css?v=19f00094" />

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../../_static/jquery.js?v=5d32c60e"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js?v=1ac0efc4"></script>
        <script src="../../../_static/doctools.js?v=888ff710"></script>
        <script src="../../../_static/sphinx_highlight.js?v=4825356b"></script>
    <script src="../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../index.html" class="icon icon-home">
            Selenium-Driverless
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/By.html">By Element Locator</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Chrome.html">webdriver.Chrome</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/ChromeOptions.html">ChromeOptions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Context.html">Context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Input.html">Input</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/RequestInterception.html">Request-Interception</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/Target.html">Target</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/WebELement.html">WebElement</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">Selenium-Driverless</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../index.html">Module code</a></li>
      <li class="breadcrumb-item active">selenium_driverless.scripts.switch_to</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for selenium_driverless.scripts.switch_to</h1><div class="highlight"><pre>
<span></span><span class="c1"># Licensed to the Software Freedom Conservancy (SFC) under one</span>
<span class="c1"># or more contributor license agreements.  See the NOTICE file</span>
<span class="c1"># distributed with this work for additional information</span>
<span class="c1"># regarding copyright ownership.  The SFC licenses this file</span>
<span class="c1"># to you under the Apache License, Version 2.0 (the</span>
<span class="c1"># &quot;License&quot;); you may not use this file except in compliance</span>
<span class="c1"># with the License.  You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#   http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1"># Unless required by applicable law or agreed to in writing,</span>
<span class="c1"># software distributed under the License is distributed on an</span>
<span class="c1"># &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span>
<span class="c1"># KIND, either express or implied.  See the License for the</span>
<span class="c1"># specific language governing permissions and limitations</span>
<span class="c1"># under the License.</span>
<span class="c1">#</span>
<span class="c1"># modified by kaliiiiiiiiii | Aurin Aegerter</span>
<span class="c1"># all modifications are licensed under the license provided at LICENSE.md</span>

<span class="kn">import</span> <span class="nn">asyncio</span>
<span class="kn">import</span> <span class="nn">typing</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span>
<span class="kn">import</span> <span class="nn">warnings</span>


<span class="kn">from</span> <span class="nn">selenium_driverless.types.by</span> <span class="kn">import</span> <span class="n">By</span>
<span class="kn">from</span> <span class="nn">selenium_driverless.types.alert</span> <span class="kn">import</span> <span class="n">Alert</span>
<span class="kn">from</span> <span class="nn">selenium_driverless.types.target</span> <span class="kn">import</span> <span class="n">TargetInfo</span><span class="p">,</span> <span class="n">Target</span>

<span class="kn">from</span> <span class="nn">selenium_driverless.types.target</span> <span class="kn">import</span> <span class="n">NoSuchIframe</span>
<span class="kn">from</span> <span class="nn">selenium_driverless.types.webelement</span> <span class="kn">import</span> <span class="n">WebElement</span><span class="p">,</span> <span class="n">NoSuchElementException</span>


<div class="viewcode-block" id="SwitchTo"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo">[docs]</a><span class="k">class</span> <span class="nc">SwitchTo</span><span class="p">:</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    the SwitchTo class</span>

<span class="sd">    .. warning::</span>
<span class="sd">        except for switching to targets, do not use this class</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">context_id</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">loop</span><span class="p">:</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">AbstractEventLoop</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
        <span class="kn">from</span> <span class="nn">selenium_driverless.types.context</span> <span class="kn">import</span> <span class="n">Context</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="p">:</span> <span class="n">Context</span> <span class="o">=</span> <span class="n">context</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_alert</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_started</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_context_id</span> <span class="o">=</span> <span class="n">context_id</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_loop</span> <span class="o">=</span> <span class="n">loop</span>
        <span class="c1"># noinspection PyProtectedMember</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_is_incognito</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">_is_incognito</span>

    <span class="k">def</span> <span class="fm">__await__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_init</span><span class="p">()</span><span class="o">.</span><span class="fm">__await__</span><span class="p">()</span>

    <span class="k">async</span> <span class="k">def</span> <span class="nf">_init</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_started</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_started</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="nd">@property</span>
    <span class="k">async</span> <span class="k">def</span> <span class="nf">alert</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Alert</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Switches focus to an alert on the page.</span>

<span class="sd">        :Usage:</span>
<span class="sd">            ::</span>

<span class="sd">                alert = target.switch_to.alert</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_alert</span><span class="p">()</span>

<div class="viewcode-block" id="SwitchTo.get_alert"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo.get_alert">[docs]</a>    <span class="k">async</span> <span class="k">def</span> <span class="nf">get_alert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">timeout</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">5</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Alert</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Switches focus to an alert on the page.</span>

<span class="sd">        :Usage:</span>
<span class="sd">            ::</span>

<span class="sd">                alert = target.switch_to.alert</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">current_target</span><span class="o">.</span><span class="n">get_alert</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="n">timeout</span><span class="p">)</span></div>

<div class="viewcode-block" id="SwitchTo.default_content"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo.default_content">[docs]</a>    <span class="k">async</span> <span class="k">def</span> <span class="nf">default_content</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">activate</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Target</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Switch focus to the default frame.</span>

<span class="sd">        :Usage:</span>
<span class="sd">            ::</span>

<span class="sd">                target.switch_to.default_content()</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">base_target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">current_target</span><span class="o">.</span><span class="n">base_target</span>
        <span class="k">if</span> <span class="n">base_target</span><span class="p">:</span>
            <span class="k">return</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">(</span><span class="n">target_id</span><span class="o">=</span><span class="n">base_target</span><span class="p">,</span> <span class="n">activate</span><span class="o">=</span><span class="n">activate</span><span class="p">)</span></div>

<div class="viewcode-block" id="SwitchTo.frame"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo.frame">[docs]</a>    <span class="k">async</span> <span class="k">def</span> <span class="nf">frame</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">frame_reference</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="n">WebElement</span><span class="p">],</span> <span class="n">focus</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Switches to the specified frame</span>

<span class="sd">        :param frame_reference: the reference by ID, name, index, or WebElement</span>
<span class="sd">        :param focus: whether to emulate focus on the frame</span>
<span class="sd">        :param focus: whether to emulate focus on the iframe</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
            <span class="s2">&quot;driver.switch_to.iframe deprecated and not reliable use Webelement.content_document instead&quot;</span><span class="p">,</span>
            <span class="ne">DeprecationWarning</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">frame_reference</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">frame_reference</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">find_element</span><span class="p">(</span><span class="n">By</span><span class="o">.</span><span class="n">ID</span><span class="p">,</span> <span class="n">frame_reference</span><span class="p">)</span>
            <span class="k">except</span> <span class="n">NoSuchElementException</span><span class="p">:</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="n">frame_reference</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">find_element</span><span class="p">(</span><span class="n">By</span><span class="o">.</span><span class="n">NAME</span><span class="p">,</span> <span class="n">frame_reference</span><span class="p">)</span>
                <span class="k">except</span> <span class="n">NoSuchElementException</span><span class="p">:</span>
                    <span class="k">pass</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">frame_reference</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">frames</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">find_elements</span><span class="p">(</span><span class="n">By</span><span class="o">.</span><span class="n">TAG_NAME</span><span class="p">,</span> <span class="s2">&quot;iframe&quot;</span><span class="p">)</span>
                <span class="n">frame_reference</span> <span class="o">=</span> <span class="n">frames</span><span class="p">[</span><span class="n">frame_reference</span><span class="p">]</span>
            <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
                <span class="k">pass</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">frame_reference</span><span class="p">,</span> <span class="n">WebElement</span><span class="p">):</span>
            <span class="k">raise</span> <span class="n">NoSuchIframe</span><span class="p">(</span><span class="n">frame_reference</span><span class="p">,</span> <span class="sa">f</span><span class="s2">&quot;couldn&#39;t get element by: </span><span class="si">{</span><span class="n">frame_reference</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="n">target</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">current_target</span><span class="o">.</span><span class="n">get_target_for_iframe</span><span class="p">(</span><span class="n">frame_reference</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">focus</span><span class="p">:</span>
            <span class="k">await</span> <span class="n">target</span><span class="o">.</span><span class="n">focus</span><span class="p">()</span>
        <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">(</span><span class="n">target</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">target</span></div>

<div class="viewcode-block" id="SwitchTo.target"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo.target">[docs]</a>    <span class="k">async</span> <span class="k">def</span> <span class="nf">target</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">target_id</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TargetInfo</span><span class="p">,</span> <span class="n">Target</span><span class="p">],</span> <span class="n">activate</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">focus</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Target</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        switches to a target</span>

<span class="sd">        :param target_id: the target to switch to</span>
<span class="sd">        :param activate: whether to bring the target to the front</span>
<span class="sd">        :param focus: whether to emulate focus on the target</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">target_id</span><span class="p">,</span> <span class="n">TargetInfo</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">_current_target</span> <span class="o">=</span> <span class="n">target_id</span><span class="o">.</span><span class="n">Target</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">target_id</span><span class="p">,</span> <span class="n">Target</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">_current_target</span> <span class="o">=</span> <span class="n">target_id</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">target_id</span><span class="p">,</span> <span class="n">WebElement</span><span class="p">):</span>
            <span class="c1"># noinspection PyDeprecation</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">_current_target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">frame</span><span class="p">(</span><span class="n">target_id</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">_current_target</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">get_target</span><span class="p">(</span><span class="n">target_id</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">activate</span><span class="p">:</span>
            <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">current_target</span><span class="o">.</span><span class="n">activate</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">focus</span><span class="p">:</span>
            <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">current_target</span><span class="o">.</span><span class="n">focus</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">current_target</span></div>

<div class="viewcode-block" id="SwitchTo.window"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo.window">[docs]</a>    <span class="k">async</span> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">window_id</span><span class="p">:</span> <span class="nb">str</span> <span class="ow">or</span> <span class="n">TargetInfo</span><span class="p">,</span> <span class="n">activate</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">focus</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Target</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        switches to a window</span>

<span class="sd">        alias to :func:`SwitchTo.target &lt;selenium_driverless.scripts.switch_to.SwitchTo.target`</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">(</span><span class="n">window_id</span><span class="p">,</span> <span class="n">activate</span><span class="o">=</span><span class="n">activate</span><span class="p">,</span> <span class="n">focus</span><span class="o">=</span><span class="n">focus</span><span class="p">)</span></div>

<div class="viewcode-block" id="SwitchTo.new_window"><a class="viewcode-back" href="../../../api/Chrome.html#selenium_driverless.scripts.switch_to.SwitchTo.new_window">[docs]</a>    <span class="k">async</span> <span class="k">def</span> <span class="nf">new_window</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">type_hint</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Literal</span><span class="p">[</span><span class="s2">&quot;tab&quot;</span><span class="p">,</span> <span class="s2">&quot;window&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;tab&quot;</span><span class="p">,</span> <span class="n">url</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">activate</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
                         <span class="n">focus</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">background</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Target</span><span class="p">:</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;creates a new tab or window</span>

<span class="sd">        :param type_hint: what kind of target to create</span>
<span class="sd">        :param url: url to start the target at</span>
<span class="sd">        :param activate: whether to bring the target to the front</span>
<span class="sd">        :param focus: whether to emulate focus on the target</span>
<span class="sd">        :param background: whether to start the target in the background</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">target</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">_context</span><span class="o">.</span><span class="n">new_window</span><span class="p">(</span><span class="n">type_hint</span><span class="o">=</span><span class="n">type_hint</span><span class="p">,</span> <span class="n">url</span><span class="o">=</span><span class="n">url</span><span class="p">,</span> <span class="n">activate</span><span class="o">=</span><span class="n">activate</span><span class="p">,</span> <span class="n">focus</span><span class="o">=</span><span class="n">focus</span><span class="p">,</span> <span class="n">background</span><span class="o">=</span><span class="n">background</span><span class="p">)</span>
        <span class="k">return</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">target</span><span class="p">(</span><span class="n">target</span><span class="p">)</span></div>

    <span class="k">async</span> <span class="k">def</span> <span class="nf">parent_frame</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">activate</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Target</span><span class="p">:</span>
        <span class="k">raise</span> <span class="bp">NotImplemented</span><span class="p">()</span></div>
</pre></div>

           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2024, Aurin Aegerter (aka Steve, kaliiiiiiiiii).</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>